﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;

namespace Tailoring
{
    public partial class frmactivetask : Form
    {
        DataTable dt;
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HTCAPTION = 0x2;
        [DllImport("User32.dll")]
        public static extern bool ReleaseCapture();
        [DllImport("User32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        public frmactivetask()
        {
            InitializeComponent();
            //dgridstatus.ColumnHeadersBorderStyle = ProperColumnHeadersBorderStyle;
        }
        public void loaddata()
        {
           
            {
                try
                {

                SqlConnection conn = new SqlConnection("Server= localhost; database=tailoringmng; integrated Security=true");
                SqlCommand cmd = new SqlCommand("undonetask",conn);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                
                if (conn == null && conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                    dt = new DataTable("myTable");
                    da.Fill(dt);
                    //BindingSource bs = new BindingSource();
                    //bs.DataSource = dt;
                //dgridstatus.DataSource = dt.DefaultView;
                
                conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                }
            }
        }
        private void frmactivetask_Load(object sender, EventArgs e)
        {
            loaddata();
        }

        private void frmactivetask_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
            }
        }

        private void dgridstatus_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
           
          //if (e.ColumnIndex == dgridstatus.Columns["btnDone"].Index && e.RowIndex >= 0)
          {
              //string searchcri = "clientId";
              //string searchkey = dt.Rows[row]["ID"].ToString();
             
              frmcus cs = new frmcus();
              cs.pidkey = dt.Rows[row]["ID"].ToString();
              cs.ddatekey = dt.Rows[row]["DeliveryDate"].ToString();
              //string daylelf = dt.Rows[row]["Days_left"].ToString();
              cs.Show();
              cs.dataloadbyddate();
              this.Refresh();
              //MessageBox.Show("this row is click" + row+"____"+searchkey);
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}

